package com.zy.bean3;


import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class SystemCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        //   获取bean工厂->获取spring 容器
        ConfigurableListableBeanFactory bf= context.getBeanFactory();
        Environment env=context.getEnvironment();  //获取环境变量
        String os=env.getProperty("os.name");    //操作系统名
        if( os.contains( "Linux")){
            return false;
        }
        return true;
    }
}
